﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Api.Common
{
    public class JsTreeModel
    {
        public override string ToString()
        {
            var setting = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
            };
            return JsonConvert.SerializeObject(this, setting);
        }

        /// <summary>
        /// 一般不用设置,不设置的话自动生成
        /// </summary>
        public string id { get; set; }
        /// <summary>
        /// 显示的文字（扩展一下显示图片）
        /// </summary>
        public string text { get; set; }
        /// <summary>
        /// 小图标（图片地址或则fa这种font的样式）
        /// </summary>
        public string icon { get; set; }
        public StateOption state { get; set; }
        public List<JsTreeModel> children { get; set; }
        /// <summary>
        /// attributes for the generated LI node
        /// </summary>
        public string li_attr { get; set; }
        /// <summary>
        /// attributes for the generated A node
        /// </summary>
        public string a_attr { get; set; }
    }

    public class StateOption
    {
        public bool opened { get; set; }
        public bool disabled { get; set; }
        public bool selected { get; set; }
    }
}
